import 'package:intl/intl.dart';

class TimeUtil {
  static const String dataFormat1 = "yyyy-MM-dd HH:mm:ss";
  static const String dataFormat2 = "yyyy-MM-dd";

  //获取当前时间戳 毫秒
  static int nowMilliseconds() {
    return DateTime.now().millisecondsSinceEpoch;
  }

  //获取当前时间戳 秒
  static int nowSeconds() {
    return DateTime.now().millisecondsSinceEpoch ~/ 1000;
  }

  static String dateFormat({DateTime? dateTime, String dataFormat = dataFormat1}) {
    DateTime date = dateTime ?? DateTime.now();
    return DateFormat(dataFormat).format(date);
  }
}
